<?php
/**
 * system common file
 * 
 * @file        $Source$
 * @package     /
 * @author      Jerry <jerryjiang15@163.com>
 * @version     $Id$
 **/

/**
 * 系统报错等级
 */
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);

/**
 * 系统路径
 */
define('SYS_PATH', '../../../../');
/**
 * Include路径
 */
define('INCLUDE_PATH', SYS_PATH . 'include/');
/**
 * 缓存目录
 */
define('CACHE_DIR', SYS_PATH . 'cache/');
/**
 * 类目录
 */
define('CLASS_PATH', INCLUDE_PATH . 'class/');
/**
 * 数据库类目录
 */
define('DB_DIR', CLASS_PATH . 'database/');
/**
 * 模板引擎目录
 */
define('TPL_DIR', CLASS_PATH . 'template/');
/**
 * 执行权限
 */
define('COMPETENCE_RUN', 2);
/**
 * 包含配置文件
 */
include_once (SYS_PATH . "config.php");  
/**
 * 包含数据库工厂文件
 */  		
include_once (DB_DIR . "db.factory.php");    	
/**
 * 包含模板引擎工厂文件
 */
include_once (TPL_DIR . "template.factory.php");    

/**
 * 包含系统调式类文件
 */
include_once (CLASS_PATH . "logger.class.php");   
/**
 * 包含缓存类文件
 */
include_once (CLASS_PATH . "cache.class.php");   

/**
 * 包含模型父类
 */
include_once (CLASS_PATH . "model.class.php");  
/**
 * 包含系统应用父类
 */
include_once (CLASS_PATH . "application.class.php");
/**
 * 包含系统session类
 */
include_once (CLASS_PATH . "session.class.php");
/**
 * 包含系统公共函数库文件
 */
include_once (INCLUDE_PATH . "functions.php"); 
/**
 * 包含文件上传类
 */
include_once (CLASS_PATH . "upload.class.php"); 
/**
 * 包含文件邮件类
 */

include_once (CLASS_PATH . "mail.class.php"); 
/**
 * 包含生成类
 */
require_once (CLASS_PATH  . 'html.class.php');

/**
 * 包含页面执行时间记录类
 */
require_once (CLASS_PATH  . 'timer.class.php');

$logger = new Logger();  //注册调试器
$logger->startTime();   //set time of program to start

$db =& DBFactory::getDBConnection($sys_conf_var['db']);   //get a batabase instance

$in_var = parse_incoming();

$tpl =& TemplateFactory::getTemplateCompiler($sys_conf_var['tpl']);   //get a Template instance
$tpl->template_dir = SYS_PATH . 'template/system/';  
$tpl->compile_dir = SYS_PATH . 'compile/';
$tpl->compile_lang = true;
$tpl->lang_dir = SYS_PATH . 'language/' . $sys_conf_var['sys']['language'] . '/admin/';
include_once (SYS_PATH . 'language/' . $sys_conf_var['sys']['language'] . '/admin.lang.php');   

$tpl->assign('sys_path',SYS_PATH);


//生成系统缓存
$cache_model = new CacheData();
if(!$cache_model->existsCache('sys')) $cache_model->makeCache('sys');
include_once(CACHE_DIR . 'cache_system_info.php');
if(!$cache_model->existsCache('cl')) $cache_model->makeCache('cl');
include_once(CACHE_DIR . 'cache_category_info.php');

$session = new Session();  //session处理类
$html = new Html();  //文件生成类
$timer = new Timer(); //执行时间记录类

$tpl->assign("executeTime", $timer->getExecuteTime());


if($_SESSION['site_session']['sid'])
{
	//print_r($_SESSION['site_session']);exit;
	$tpl->assign('SessionUserInfo',$_SESSION['site_session']);
	
}

$upload = new Upload(); //声明上传类



$upload->setMaxLength($sys_info['filesize']*1024*1024);

if($sys_info['filetype'])
{
	$allow_type = explode(',',$sys_info['filetype']);
	foreach ($allow_type as $key => $value)
	{
		$upload->setAllowType($value);
	}
}

header ("Content-type: text/html; charset=utf-8");

?>